package com.ruoyi.web.controller.acitviti;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.workFlow.service.OperationalWorkFlowService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @ClassName OperationalWorkFlowController
 * @Description 运营需求单执行流程Controller
 * @Author leizhang
 * Date 2021/11/4 2:24 下午
 * @Version 1.0
 **/
@RestController
@RequestMapping("/operationalWorkFlowApi")
public class OperationalWorkFlowController {

    private static Logger LOGGER = LoggerFactory.getLogger(OperationalWorkFlowController.class);

    @Resource
    private OperationalWorkFlowService operationalWorkFlowService;

    /**
     * @param requestParam
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @Description : 启动运营单流程实例
     * @Author : leizhang
     * @Date 2:27 下午 2021/11/4
     **/
    @PostMapping("/startOperationalWorkFlow")
    public AjaxResult startOperationalWorkFlow(@RequestBody Map<String, Object> requestParam) {
        try {
            operationalWorkFlowService.startOperationalWorkFlowProcess(requestParam);
            return AjaxResult.success();
        } catch (Exception e) {
            LOGGER.error("运营需求单流程启动失败:{}", e.getCause(), e);
            return AjaxResult.error();
        }
    }
}
